<?php

/**
 * 后台首页
 * ============================================================================
 * TBlog TBlog博客系统　BY Tmac PHP MVC framework
 * $Author: zhangwentao $  <zwttmac@qq.com>
 * $Id: IndexAction.php 1459 2011-03-04 09:41:11Z zhangwentao $
 * http://www.t-mac.org；
 */
class indexAction extends Action
{

    //定义初始化变量
    private $menu;

    public function _init()
    {
        //加载并返回Model文件夹下的Model对象。
        $this->menu = Tmac::model('admin.Menu');
        $check_model = $this->M('admin.check');
        $check_model->checkLogin();
        $check_model->CheckPurview('i_admin,i_editer');
    }

    public function index()
    {
        $admin_dir = $GLOBALS['TmacConfig']['Template']['template_admin_dir'];
        $menusMain = "
        <m:top mapitem='0' name='链接' rank='i_admin'>
          <m:item name='链接管理' link='index.php?m={$admin_dir}/link' rank='i_admin' target='main' />
          <m:item name='添加新链接' link='index.php?m={$admin_dir}/link.add' rank='i_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='分类' rank='i_admin'>
          <m:item name='分类管理' link='index.php?m={$admin_dir}/category' rank='i_admin' target='main' />
          <m:item name='添加分类' link='index.php?m={$admin_dir}/category.add' rank='i_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='用户' rank='i_admin'>
          <m:item name='用户管理' link='index.php?m={$admin_dir}/user' rank='i_admin' target='main' />
          <m:item name='添加新用户' link='index.php?m={$admin_dir}/user.add' rank='i_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='工具' rank='i_admin'>
          <m:item name='数据库备份' link='index.php?m={$admin_dir}/data.back' rank='i_admin' target='main' />
          <m:item name='数据库还原' link='index.php?m={$admin_dir}/data.revert' rank='i_admin' target='main' />
        </m:top>

        <m:top mapitem='0' name='设置' rank='i_admin'>
          <m:item name='网站设置' link='index.php?m={$admin_dir}/config' rank='i_admin' target='main' />
          <m:item name='退出系统' link='index.php?m={$admin_dir}/login.out' rank='i_admin' target='main' />
        </m:top>
        ";
        $this->assign('menua', $this->menu->getMenua($menusMain));
        $this->AV();
    }

    public function body()
    {        
        $verLockFile = VAR_ROOT . '/Data/ver.txt';
        $fp = fopen($verLockFile, 'r');
        $upTime = trim(fread($fp, 64));
        fclose($fp);         
        $this->assign('gdversion', $this->menu->gdversion());
        $this->assign('upTime', $upTime);
        $this->AV('index_body');
    }

}